package demo04ArrayListLinkedList;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:咭咭熊
 * Date:2021 - 09 - 21
 * Time:16:33
 */
public class TestDoubleLinkedList {
    public static void main(String[] args) {
        myDoubleLinkedList myDoubleLinkedList = new myDoubleLinkedList();
        myDoubleLinkedList.addLast(1);
        myDoubleLinkedList.addLast(1);
        myDoubleLinkedList.addLast(1);
        myDoubleLinkedList.addLast(1);
        myDoubleLinkedList.addLast(7);
        myDoubleLinkedList.addLast(8);
        myDoubleLinkedList.display();//1 1 1 1 7 8
        myDoubleLinkedList.clea2();
        System.out.println("=============");
    }
    public static void main3(String[] args) {
        myDoubleLinkedList myDoubleLinkedList = new myDoubleLinkedList();
        myDoubleLinkedList.addLast(1);
        myDoubleLinkedList.addLast(1);
        myDoubleLinkedList.addLast(1);
        myDoubleLinkedList.addLast(1);
        myDoubleLinkedList.addLast(7);
        myDoubleLinkedList.addLast(8);
        myDoubleLinkedList.display();//1 1 1 1 7 8
        myDoubleLinkedList.removeAllKey(1);
        myDoubleLinkedList.display();// 7 8

    }
    /***
     * 2.测试链表是否包含某个元素key 和删除某个节点
     * @param args
     */
    public static void main2(String[] args) {
        myDoubleLinkedList myDoubleLinkedList = new myDoubleLinkedList();
        myDoubleLinkedList.addLast(5);
        myDoubleLinkedList.addLast(6);
        myDoubleLinkedList.addLast(7);
        myDoubleLinkedList.addLast(8);
        myDoubleLinkedList.display();// 5 6 7 8
        boolean ret = myDoubleLinkedList.contains(6);
        System.out.println(ret);

        myDoubleLinkedList.remove1(6);
        myDoubleLinkedList.display();//5 7 8
        myDoubleLinkedList.remove1(5);
        myDoubleLinkedList.display();// 7 8
    }
    /***
     * 1.测试双向链表的头插法和尾插法
     * @param args
     */
    public static void main1(String[] args) {
        myDoubleLinkedList myDoubleLinkedList = new myDoubleLinkedList();
        myDoubleLinkedList.addFirst(1);
        myDoubleLinkedList.addFirst(2);
        myDoubleLinkedList.addFirst(3);
        myDoubleLinkedList.addFirst(4);
        myDoubleLinkedList.display();// 4 3 2 1
        myDoubleLinkedList.addLast(5);
        myDoubleLinkedList.addLast(6);
        myDoubleLinkedList.display();//4 3 2 1 5 6
        myDoubleLinkedList.addIndex(0,99);
        myDoubleLinkedList.addIndex(1,99);
        myDoubleLinkedList.addIndex(4,99);
        myDoubleLinkedList.display();// 99 99 4 3 99 2 1 5 6
    }
}
